I have created a simple react app with create-react-app and I have integrated it with electron successfully. Everything was working great until I tried to import electron inside the action creator file. If I remove the line below, the app works fine. The problem is that I can't use the ipcRenderer to communicate from the react side to the electron main process.
This line causes the app to crash: import { ipcRenderer } from 'electron';
I get the following error:
TypeError: fs.existsSync is not a function (anonymous function) node_modules/electron/index.js:6
3 | 4 | var pathFile = path.join(__dirname, 'path.txt') 5 |
6 | if (fs.existsSync(pathFile)) { 7 | module.exports = path.join(__dirname, fs.readFileSync(pathFile, 'utf-8')) 8 | } else { 9 | throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again')